<?php namespace Common\Model;
use Hdphp\Model\Model;
use Common\Model\Shop_attribute;
class Shop_list extends Model{
	protected $table='shop_list';
	public function store(){
		if($this->create()){
//			p($this->data);exit;
			$shop_id=$this->data['sid'];			
			foreach($this->data['combine'] as $v){
			$Shop_attributeModel=new Shop_attribute;
			$combine[]=$Shop_attributeModel->where("shop_id={$shop_id} AND shop_attributecol='$v'")->pluck('sid');
			}
//			p($combine);exit;
			$this->data['combine']=implode(',', $combine);
//			p($this->data);exit;
			$this->add();
			return true;
		}
		else return FALSE;
	}
	public function edit(){
		if($this->create()){
			$slid=Q('post.slid');
			
//			p($this->data);exit;
			$shop_id=$this->data['sid'];			
			foreach($this->data['combine'] as $v){
			$Shop_attributeModel=new Shop_attribute;
			$combine[]=$Shop_attributeModel->where("shop_id={$shop_id} AND shop_attributecol='$v'")->pluck('sid');
			}
//			p($combine);exit;
			$this->data['combine']=implode(',', $combine);
//			p($this->data);exit;
			$this->where("slid={$slid}")->save();
			return true;
		}
		else return FALSE;
	}
} 